<template>
	<view style="height: 100vh;" class="bg-white padding">
		<view class="padding-bottom">
			加客服微信后回复需要加哪个地区的，拉你进群，如果提示被加好友频繁，请耐心等候。
			<view class="padding-top-sm">
				也可以关注官方公众号，每日发布最新招聘求职信息。
			</view>
		</view>
		
		<view class="padding-top">
			<view class="flex padding-bottom" style="line-height: 30px;">
				<view class="flex-treble text-right padding-right">
					微信号：{{ wechat }} 
				</view>
				<view class="flex-twice">
					<button @tap="copy('1')" data-clipboard-action="copy" :data-clipboard-text="wechat" class="copy-btn cu-btn bg-green">快速复制</button>
				</view>
			</view>
			<view class="flex padding-top" style="line-height: 30px;">
				<view class="flex-treble text-right padding-right">
					公众号：{{ gzh }} 
				</view>
				<view class="flex-twice">
					<button @tap="copy('2')" data-clipboard-action="copy" :data-clipboard-text="gzh" class="copy-btn cu-btn bg-green">快速复制</button>
				</view>
			</view>
		</view>
		
		<view class="cu-modal" :class="showModal?'show':''">
			<view class="cu-dialog">
				<view class="cu-bar bg-white justify-end">
					<view class="content">提示</view>
					<view class="action" @tap="showModal = false">
						<text class="cuIcon-close text-red"></text>
					</view>
				</view>
				<view class="padding-xl">
					{{ type=='1'? '微信号复制成功，快去微信-添加朋友-搜索框粘贴吧' : '公众号复制成功，快去微信-搜索框粘贴吧' }}
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import Clipboard from 'clipboard'
	export default {
		data() {
			return {
				wechat: 'zhongLvTech ',
				gzh: '镖掌柜招聘 ',
				type: '1',
				showModal: false,
				wxpage: 'https://mp.weixin.qq.com/s/Ii6X0Te9PutZBdqL28oQ5A'
			};
		},
		onLoad(option) {
			var ua = window.navigator.userAgent.toLowerCase();
			if (ua.match(/micromessenger/i) == 'micromessenger') {
				location.href = this.wxpage
			}
			this.getConfig()
		},
		methods: {
			getConfig(){
				let config = uni.getStorageSync('config')
				if(config){
					this.wechat =config.find(v=>v.parmName=='h5_wechat_group').value
					this.gzh = config.find(v=>v.parmName=='h5_wechat_group_gzh').value
				}
			},
			copy(type) {
				let _this = this;
				let clipboard = new Clipboard(".copy-btn");
				clipboard.on('success', function() {
					_this.type = type;
					_this.showModal = true;
					setTimeout(()=>{
						_this.showModal = false;
					}, 3000)
				});
				clipboard.on('error', function() {
					_this.showModal = false;
					setTimeout(()=>{
						uni.showToast({
							title: '复制失败'
						})
					}, 500);
				});
			}
		}
	}
</script>
